import "../scss/index2.scss";

import "../swiper/swiper.min.css";
import "../swiper/animate.min.css";
import "../css/iconfont/iconfont.css";

import * as Swiper from "../swiper/swiper.js";
import {WOW} from "../swiper/wow.js";

require ("swiper-animate-cn");

var swiperAnimateCache = require("swiper-animate-cn").swiperAnimateCache;
var swiperAnimate = require("swiper-animate-cn").swiperAnimate;
var clearSwiperAnimate = require("swiper-animate-cn").clearSwiperAnimate;

//整合该页面用到的所有js
import{getIndex2} from "./request.js";
//引入懒加载
import{lazyLoad}from "../utils/lazyLoad.js";

//获取页面所有图片
let Imgs = document.querySelectorAll('header img,main img')
console.log(Imgs);

async function xixi(){
  let tp = await getIndex2();
  console.log(tp);
  let tp1 = [];
  tp.results.forEach(function(item){
    tp1.push(item.photo_detal.url);
  })
  Imgs.forEach(function(item,index){
    item.setAttribute("data-src",tp1[index])
  })

  lazyLoad(Imgs);
}
xixi();

//宽高公式
// function vw(w){
//     return (w/1910) * 100 + "vw";
// }

//导航栏吸顶
// let nav = document.querySelector(".nav");
// window.onscroll = function () {
//   let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
//   scrollTop < 300 ? (nav.style.top = vw(-80)) : (nav.style.top = 0);
// };

//轮播图  
let mySwiper = new Swiper(".swiper-container", {
    //切换效果
    effect: "cards",
    cardsEffect: {
      slideShadows: true,
      //transformEl:'.text',
    },
    //轮播图方向
    direction: "horizontal", //水平的
  
    //分页器 --轮播图的小点点
    pagination: {
      el: ".swiper-pagination",
      clickable: true,
    },
  
    //配置上一页下一页按钮
      navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },
  
    //自动播放
    autoplay: {
      delay: 2000, //时间
      stopOnLastSlide: false, //是否在最后一张停止
      disableOnInteraction: true, //用户点击时停止播放
    },
  
    on: {
      init: function () {
        swiperAnimateCache(this); //隐藏动画元素
        swiperAnimate(this); //初始化完成开始动画
      },
      slideChangeTransitionEnd: function () {
        swiperAnimate(this); //每个slide切换结束时也运行当前slide动画
        //this.slides.eq(this.activeIndex).find('.ani').removeClass('ani'); 动画只展现一次，去除ani类名
      },
    },
  });

  //展示--创意设计、新闻动态、公司视频

  new WOW().init()




